package cz.data.gateway.admin.rest;

import cz.data.common.base.TableDataResponse;
import cz.data.gateway.model.utils.RouteConstant;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CommonController {

    @ApiOperation(value = "获取网关路由断言选项")
    @GetMapping("/api/admin/gateway/predicate/options")
    public TableDataResponse<RouteConstant.FactoryOptions> predicateFactoryOptions() {
        List<RouteConstant.FactoryOptions> predicateFactory = RouteConstant.PREDICATE_FACTORY;
        return new TableDataResponse<>(predicateFactory, predicateFactory.size());
    }

    @ApiOperation(value = "获取网关路由过滤选项")
    @GetMapping("/api/admin/gateway/filter/options")
    public TableDataResponse<RouteConstant.FactoryOptions> filterFactoryOptions() {
        List<RouteConstant.FactoryOptions> predicateFactory = RouteConstant.FILTER_FACTORY;
        return new TableDataResponse<>(predicateFactory, predicateFactory.size());
    }
}
